package demo.util_ui.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockPanel;

/**
 * Dialog with yes/no buttons.
 * 
 * @author psriplakich
 *
 */
public abstract class YesNoDialog extends AbstractDialog {

	final Button yesButton = new Button("Ok");

	final Button noButton = new Button("Cancel");

	public YesNoDialog(final String yesLabel, final String noLabel) {
		super();

		this.yesButton.setHTML(yesLabel);
		// Add a handler to close the DialogBox
		this.yesButton.addClickHandler(new ClickHandler() {
			public void onClick(final ClickEvent event) {

				hide();
				onYes();

			}
		});

		this.noButton.setHTML(noLabel);
		// Add a handler to close the DialogBox
		this.noButton.addClickHandler(new ClickHandler() {
			public void onClick(final ClickEvent event) {
				hide();
				onNo();
			}
		});

		this.bottomPanel.add(this.noButton, DockPanel.EAST);
		this.bottomPanel.add(this.yesButton, DockPanel.EAST);

	}

	protected abstract void onNo();

	protected abstract void onYes();
}
